<?php
namespace app\serverarticle\validate;

use \app\manage\validate\BaseValidate;
/**
 * @Author: 蒋哲
 * @Date:   2017-05-25 11:49:42
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-05-27 10:46:23
 */
class Article extends BaseValidate
{
    protected $rule = [
        'id'          => ['require'],
        'title'       => ['require', 'min'=>2, 'max'=>50],
        'classify_id' => ['require'],
        'content'     => ['require'],
        'author'      => ['require', 'min'=>2, 'max'=>10],
        'writer_id'   => ['require'],
        'nickname'    => ['chsAlphaNum'],
        'audit_id'    => ['require'],
        'classify_id' => ['require']
    ];

    protected $message = [
        'title.require'       => '文章标题不能为空！',
        'classify_id.require' => '文章分类id不能为空！',
        'content.require'     => '文章内容不能为空！',
        'writer_id.require'   => '发布人id不能为空！',
        'author.require'      => '作者不能为空！',
        'author.min'          => '作者名不能短于两个字！',
        'author.max'          => '作者名不能长于十个字！'
    ];

    protected $scene = [
        'add'    => ['title', 'classify_id', 'author', 'content', 'writer_id','nickname'],
        'edit'   => ['id', 'title','nickname', 'author'],
        'status' => ['id'=>['require','integer','gt'=>0]],
        'audit'  => ['id','audit_id'],
        'list'   => ['classify_id'],
    ];
}